package com.eleventwelve.iris.web.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.eleventwelve.iris.entity.MedicalProgramTreatment;

public class MedicalProgramTreatmentValidator implements Validator{

	@Override
	public boolean supports(Class<?> arg0) {
		return MedicalProgramTreatment.class.isAssignableFrom(arg0);
	}

	@Override
	public void validate(Object obj, Errors err) {
		
		MedicalProgramTreatment treatment = (MedicalProgramTreatment) obj;
		if(treatment.getIsCompleted()){
			ValidationUtils.rejectIfEmptyOrWhitespace(err, "transientDate", "error.required-field", new Object[]{"Treatment Date"});
		}
		
		
	}

}
